<template>
  <!-- 列表 -->
  <ContentWrap title="系统存储">
    <el-table row-key="id" border :header-cell-style="{ background: '#e6f7ef', color: '#008c46' }" v-loading="loading"
      :data="list" :stripe="true" :show-overflow-tooltip="true" @selection-change="handleRowCheckboxChange">
      <el-table-column label="描述" align="center" prop="storageDescr" />
      <el-table-column label="存储总容量(GB)" align="center" prop="totalGb" />
      <el-table-column label="已使用(GB)" align="center" prop="usedGb" />
      <el-table-column label="剩余(GB)" align="center" prop="freeGb" />
      <el-table-column label="使用率" align="center" prop="storagePerc" width="120">
        <template #default="scope">
          <div class="demo-progress">
            <el-progress :percentage="scope.row.storagePerc" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="告警阈值" align="center" prop="storagePercWarn" />
    </el-table>
  </ContentWrap>
</template>

<script setup lang="ts">
import { StorageApi, Storage } from '@/api/business/storage'
import { number } from 'vue-types'

/** 存储表 列表 */
defineOptions({ name: 'Storage' })


// 声明接收的 props
const props = defineProps({
  devices: {
    type: Object,
    required: true
  }
})


const loading = ref(true) // 列表的加载中
const list = ref<Storage[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
  deviceId: undefined,
})

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await StorageApi.getStorageList(queryParams)
    console.log("dataaaa", data);

    list.value = data
  } finally {
    loading.value = false
  }
}


const checkedIds = ref<number[]>([])
const handleRowCheckboxChange = (records: Storage[]) => {
  checkedIds.value = records.map((item) => item.id!);
}


/** 初始化 **/
onMounted(() => {
  // queryParams.deviceId = props.devices.id
  queryParams.deviceId = 138
  getList()
})
</script>